package com.cybertooth.dbconvenience.query.core;

import org.apache.commons.lang.StringUtils;

/**
 * <p></p>
 *
 * @author dnelson
 */
public class Table implements SqlTransformer {

	// -----------------------------------------------------------------------Fields

	protected String alias;
	protected String name;

	// -----------------------------------------------------------------Constructors

	public Table(String name) {
		this.name = name;
	}

	public Table(String alias, String name) {
		this.alias = alias;
		this.name = name;
	}

	// ---------------------------------------------------------------Public Methods

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toSql() {
		String alias = StringUtils.isBlank(this.alias) ? "" : this.alias + " ";
		return new StringBuilder().append(" ").append(this.name).append(" ").append(alias).toString();
	}
}
